package com.springboot.consumer.service;

import com.springboot.consumer.dao.UserDao;
import com.springboot.consumer.dao.UserFeignClient;
import com.springboot.consumer.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author XiaoLuo
 * @ClassName: UserService
 * @Description: ${todo}
 * @date 2019/4/6 21:31
 */
@Service
public class UserService {
    @Autowired
    private UserDao userDao;

    @Autowired
    private UserFeignClient userFeignClient;

    public List<User> queryUserByIds(List<Long> ids){
        List<User> users = new ArrayList();
        for (Long id : ids) {
//            User user = this.userDao.queryUserById(id);
            User user = null;
            try {
                user = this.userFeignClient.queryById(id);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            users.add(user);
        }
        return users;
    }
}
